package com.xuanyue.db.xuan.antlr.v2.impl;

import java.util.Comparator;
import java.util.Map;

import com.xuanyue.db.xuan.core.table.IXyTable;
import com.xuanyue.db.xuan.core.table.expr.ExprValue;

public class SortComparator implements Comparator<Map<String, ExprValue>>{

	@Override
	public int compare(Map<String, ExprValue> o1, Map<String, ExprValue> o2) {
		byte[] s1 = o1.get(  IXyTable.SORT_OBJECT_NAME ).getValue();
		byte[] s2 = o2.get(  IXyTable.SORT_OBJECT_NAME ).getValue();
		for(int i=0,s=s1.length;i<s;i++) {
			if(s1[i]>s2[i]) {
				return -1;
			}else if(s1[i]<s2[i]) {
				return 1;
			}
		}
		return 0;
	}
}
